<?php

require_once("controllers/init.php");
require_once("model/classes/events/EventsResultSet.php");
require_once("model/classes/events/ICalendar.php");


$results = new EventsResultSet();
$from = new DateTime("now");
$from->modify("-1 month");

$to = new DateTime("3000-01-01");

$results->setTo($to);
$results->setFrom($from);

// clerks involvee id = 1
$involveeID = 1;

$sql = "SELECT Ev.*,Inv.EventInvolveeNameID FROM Events as Ev ";
$sql .= "INNER JOIN EventInvolvees AS Inv ON Ev.EventID = Inv.EventID ";
$sql .= "WHERE Ev.Start > '".$from->format("Y-m-d H:i")."' ";
$sql .= "AND Ev.DeletedBy = 0 ";
$sql .= "AND Inv.EventInvolveeNameID = ".$involveeID." ";
$sql .= "ORDER BY Ev.Start,Ev.EventID";


$results->setSql($sql);


$calendar = new ICalendar();
$calendar->setEventsResultSet($results);
$calendar->showComment(false);
$calendar->showLocations(true);
$calendar->showInvolvees(false);
$calendar->getCalendar();
		
